﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace gChartSharp
{
    /// <summary>
    /// 
    /// </summary>
    public class MapColorParam : IRenderable
    {
        /// <summary>
        /// The name of the API
        /// </summary>
        public string Name { get { return "chco"; } }


        /// <summary>
        /// The color of any countries or states that do not have
        /// an explicit color defined.
        /// </summary>
        public Color BackgroundRegions { get; set; }


        public List<Color> GradientColors
        {
            get { return mGradientColors ?? (mGradientColors = new List<Color>()); }
            set { mGradientColors = value; }
        }
        private List<Color> mGradientColors;


        /// <summary>
        /// The default constructor
        /// </summary>
        public MapColorParam() { }


        /// <summary>
        /// Renders the API text
        /// </summary>
        /// <returns></returns>
        public string Render()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(String.Format("&{0}={1}", Name, BackgroundRegions.ToHtml()));

            if (GradientColors.Count > 0)
            {
                GradientColors.ForEach((Color color) =>
                    {
                        sb.Append(String.Format(",{0}", color.ToHtml()));
                    });
            }

            return sb.ToString();
        }

    }
}
